package cn.bugstack.middleware.db.router.dynamic;

import cn.bugstack.middleware.db.router.DBContextHolder;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author wcc
 * @description 动态数据源类
 * @create
 */

public class DynamicDataSource extends AbstractRoutingDataSource {

    //获取路由设置到 ThreadLocal 的结果
    @Override
    protected Object determineCurrentLookupKey() {
        return "db" + DBContextHolder.getDBKey();
    }
}
